package jungletimers;


import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
import jungletimers.CreepTimerPanel;
import jungletimers.CreepTimerPanelFactory;
import net.miginfocom.swing.MigLayout;

/**
 *
 * @author nmaludy
 */
public class NeutralPanel extends JPanel {

    private static final long serialVersionUID = 1L;

    private final CreepTimerPanel baronTimer;
    private final CreepTimerPanel dragonTimer;

    public NeutralPanel(Timer timer) {
        super();
        this.baronTimer = CreepTimerPanelFactory.newBaronTimer();
        this.dragonTimer = CreepTimerPanelFactory.newDragonTimer();
        associateTimers(timer);
        layoutUi();
    }

    private void associateTimers(Timer timer) {
        timer.addActionListener(baronTimer);
        timer.addActionListener(dragonTimer);
    }

    private void layoutUi() {
        MigLayout ml = new MigLayout("align center, insets 0 0 0 0", //Layout constraints
                "[fill][fill, center][fill]", //column constraints
                "[fill]"); //row constraints
        super.setLayout(ml);
        super.add(new JLabel(), "grow");
        super.add(baronTimer, "grow, wrap");
        super.add(new JLabel(), "grow");
        super.add(dragonTimer, "grow,");
    }

    public void resetTimers() {
        this.baronTimer.reset();
        this.dragonTimer.reset();
    }
}
